package com.qunar.support.util;

import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;

import org.json.JSONObject;
import org.junit.Test;

public class TestCal {
	public static void main(String[] args) throws Exception {
		Calendar.getInstance();
		long startTime = System.currentTimeMillis();
		for (int i = 0; i < 10000000; i++) {
			Calendar cal = Calendar.getInstance();
			cal.setTimeInMillis(startTime);
			System.out.println(cal.get(Calendar.DAY_OF_YEAR));
		}
		System.out
				.println("total: " + (System.currentTimeMillis() - startTime));
		Calendar cal = Calendar.getInstance();
		startTime = System.currentTimeMillis();
		for (int i = 0; i < 10000000; i++) {
			synchronized (cal) {
				cal.setTimeInMillis(startTime);
				System.out.println(cal.get(Calendar.DAY_OF_YEAR));
			}
		}
		System.out
				.println("total: " + (System.currentTimeMillis() - startTime));
	}

	@Test
	public void run() {
		Date now = new Date();
		DateFormat d1 = DateFormat.getDateTimeInstance(); // 默认语言（汉语）下的默认风格（MEDIUM风格，比如：2008-6-16 20:54:53）
		String str1 = d1.format(now);
		System.out.println(str1);
		JSONObject json = new JSONObject();   
//        json.put("id", 007);   
//        json.put("name", "james");
	}
}
